/*
 * @Author: many
 * @Date: 2020-06-21 17:20:52
 * @LastEditors: di
 * @LastEditTime: 2020-06-23 15:08:11
 * @Description: file content
 */


import request from "@/utils/request";
import { getQueryObject } from "@/utils";

// location.href
// console.log("location.href", getQueryObject());
/**
 * @description 时间时间轴数据
 * @param {object} data
 */
export function getOrderLine() {
  const formData = new FormData();
  formData.append("workorderId", getQueryObject().workorderId);
  return request({
    url: "/service/service-app/detailWorkOrder",
    method: "post",
    data: formData,
  });
}

/**
 * @description  确认工单
 * @param {string} workorderId
 */
export function sureWorkOrder() {
  const formData = new FormData();
  formData.append("workorderId", getQueryObject().workorderId);
  return request({
    url: "/service/service-app/confirmWorkOrder",
    method: "post",
    data: formData,
  });
}

/**
 * @description  驳回工单 workorderId必填，驳回原因content和附件fileGroupId不必填
 * @param {object} object
 */
export function rejectWorkOrder(object) {
  const formData = new FormData();
  formData.append("workorderId", getQueryObject().workorderId);
  formData.append("content", object.content);
  formData.append("fileGroupId", object.fileGroupId);
  return request({
    url: "/service/service-app/rejectWorkOrder",
    method: "post",
    data: formData,
  });
}

/**
 * @description 评价工单 satisfaction必填，评价内容content和附件fileGroupId不必填
 * @param {object} object
 */
export function evaluateWorkOrder(object) {
  const formData = new FormData();
  formData.append("workorderId", getQueryObject().workorderId);
  formData.append("satisfaction", object.satisfaction);
  formData.append("content", object.content);
  formData.append("fileGroupId", object.fileGroupId);
  return request({
    url: "/service/service-app/evaluateWorkOrder",
    method: "post",
    data: formData,
  });
}
